SPB Git forge

spb/immbot-ai

Public
1commits 1branches 0releases
1.5 MBsize
maindefault branch
20 days agolast push
TypeScript 98.3% CSS 0.9% Shell 0.7%
933 B · 25 lines tsx
Raw Blame History
1import { Suspense } from "react";2import { notFound } from "next/navigation";3import { requireUser } from "@/lib/auth/session.ts";4import { all, get } from "@/lib/db/index.ts";5import { ChatApp } from "@/components/chat/chat-app";67export const metadata = { title: "Chat" };89export default async function ChatConversationPage(ctx: { params: Promise<{ id: string }> }) {10  const user = await requireUser();11  const id = parseInt((await ctx.params).id, 10);12  const conv = get("SELECT id FROM conversations WHERE id = ? AND user_id = ?", id, user.id);13  if (!conv) notFound();14  const courses = all<{ code: string; title: string; color: string }>(15    `SELECT c.code, c.title, c.color FROM courses c JOIN enrollments e ON e.course_code = c.code16     WHERE e.user_id = ? AND c.active = 1 ORDER BY c.code`,17    user.id18  );19  return (20    <Suspense>21      <ChatApp courses={courses} initialConversationId={id} />22    </Suspense>23  );24}25